/** @file ButtonToolbar.qml
@brief Iconic button with custom image and optional text

ButtonToolbar is a object subloaded by the toolbar builder. Should not
be used for normal operations. Use \e ButtonIcon instead.

@authorname \n
@licenseversion \n
@actualversion - @dateupdate

@licensenote
*/

import QtQuick 1.0
import "Theme.js" as JObj
import "Math.js"as JMath

Item {
    id: buttonToolbar

    width: objSubLoad.getWidth()
    height: objSubLoad.getHeight()
    signal objClicked

    Row {
        height: parent.height; width: parent.width
        spacing: objSubLoad.getFieldSpacing()

        Image { id: button; source: objSubLoad.getIcon(); fillMode: Image.PreserveAspectFit }

        Text {
            id: buttonText
            text: objSubLoad.getString(); verticalAlignment: Text.AlignVCenter; color: "white"; smooth: true
            font.pointSize: objSubLoad.getFontPoints() - 2;
        }
    }

    // Shade is set over the entire button when it is presed
    Rectangle { id: shade; anchors.fill: buttonToolbar; radius: 5; color: "black"; opacity: 0 }

    MouseArea {
        id: mouseArea
        anchors.fill: buttonToolbar
        onClicked: { buttonToolbar.objClicked(); }
    }

    // When button is pressed the shade changes
    states: State {
        name: "pressed"; when: mouseArea.pressed == true
        PropertyChanges { target: shade; opacity: .2 }
    }
}

